#ifndef __CONTINUATION_H__
#define __CONTINUATION_H__

#define CONTINUATION_EVENT_NONE 0

#define CONTINUATION_DONE 0
#define CONTINUATION_CONT 1


#include "I_Lock.h"

class Continuation;
class ProxyMutex;

typedef int (Continuation::*ContinuationHandler)(int event, void *data);

class Continuation{
public:
	ContinuationHandler handler;

	int handleEvent(int event = CONTINUATION_EVENT_NONE, void *data = 0)
	{
		return (this->*handler)(event, data);
	}

	Continuation(ProxyMutex *amutex = NULL)
	{
		mutex = amutex;
	}

	Ptr<ProxyMutex> mutex;
};


#define SET_HANDLER(_h) (handler = (ContinuationHandler)_h)
#define SET_CONTINUATION_HANDLER(_c, _h) (_c->handler = (ContinuationHandler)_h)


#endif //__CONTINUATION_H__
